/*
Kakine
ActionScript Framework
Copyright © 2011, PUNY, LLC.

This file is part of KAKINE.

KAKINE is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

KAKINE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with KAKINE.  If not, see <http://www.gnu.org/licenses/>.
*/ 
package com.puny.ball.views.maps
{
	import flash.display.MovieClip;
	import flash.geom.Point;

	public class Accelerator extends MovieClip
	{
		private const RADIAN:Number = Math.PI / 180;
		protected var _acc:Number;
		private const _acceleration:Point = new Point();
//		private const _velocity:Point = new Point();
		/**
		 * 
		 * @param acc acceration. In default, its flows from left to right. If this asset is rotated, it's followed by the rotation.
		 * 
		 */
		public function Accelerator(acc:Number=1.5)
		{
			_acc = acc;
			super();
			initialize();
		}
		
		/**
		 * 
		 * @return 
		 * 
		 */
		public function get acceleration():Point {
//			trace("acceleration=",_acc);
			return _acceleration;
		}
		
//		public function get velocity():Point {
//			return _velocity;
//		}
		
		public function set acc(value:Number):void {
			_acc = value;
			initialize();
		}
		
//		public function setVelocity(x:Number,y:Number):void {
//			_velocity.x = x;
//			_velocity.y = y;
//		}
		
		override public function set rotation(value:Number):void {
			super.rotation = value;
			initialize();
		}
		
		private function initialize():void {
			var rad:Number = rotation * RADIAN;
			_acceleration.y = _acc * Math.sin(rad);
			_acceleration.x = _acc * Math.cos(rad);
			
		}
	}
}